﻿using System;
using System.Configuration;

namespace MultiViewer.Display
{
    public class MasterConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("width", IsRequired = true)]
        public int Width
        {
            get { return (int)this["width"]; }
            set 
            {
                if (value < 1)
                    throw new ArgumentException("Display grid width must be positive");
                this["width"] = value; 
            }
        }

        [ConfigurationProperty("height", IsRequired = true)]
        public int Height
        {
            get { return (int)this["height"]; }
            set             
            {
                if (value < 1)
                    throw new ArgumentException("Display grid height must be positive");
                this["height"] = value; 
            }
        }

        [ConfigurationProperty("display", IsRequired = true)]
        public DisplayConfigurationElement Display
        {
            get { return (DisplayConfigurationElement)this["display"]; }
            set { this["display"] = value; }
        }
    }

    public class DisplayConfigurationElement : ConfigurationElement
    {
        [ConfigurationProperty("fullscreen", IsRequired = false, DefaultValue = false)]
        public bool Fullscreen
        {
            get { return (bool)this["fullscreen"]; }
            set { this["fullscreen"] = value; }
        }

        [ConfigurationProperty("width", IsRequired = true)]
        public int Width
        {
            get { return (int)this["width"]; }
            set 
            {
                if (value < 1)
                    throw new ArgumentException("Display width in pixels must be positive");
                this["width"] = value; 
            }
        }

        [ConfigurationProperty("height", IsRequired = true)]
        public int Height
        {
            get { return (int)this["height"]; }
            set
            {
                if (value < 1)
                    throw new ArgumentException("Display height in pixels must be positive");
                this["height"] = value;
            }
        }
        [ConfigurationProperty("cursorwidth", IsRequired = true)]
        public int CursorWidth
        {
            get { return (int)this["cursorwidth"]; }
            set
            {
                if (value < 1)
                    throw new ArgumentException("Cursor width in pixels must be positive");
                this["cursorwidth"] = value;
            }
        }
        [ConfigurationProperty("cursorheight", IsRequired = true)]
        public int CursorHeight
        {
            get { return (int)this["cursorheight"]; }
            set
            {
                if (value < 1)
                    throw new ArgumentException("Cursor height in pixels must be positive");
                this["cursorheight"] = value;
            }
        }
        [ConfigurationProperty("mousepress", IsRequired = true)]
        public bool MousePress
        {
            get { return (bool)this["mousepress"]; }
            set
            {
                this["mousepress"] = value;
            }
        }
    }

    


}